;
layui.define([ "table", "form" ], function(exports) {
	tab = layui.table, form = layui.form;
	tab.render({
		elem : "#LAY-web-list",
		url : layui.setter.base + "admin/merch/listJson",
		cols : [ [ {
			field : "code",
			title : "用户编号",
			sort : !0
		}, {
			field : "name",
			title : "用户名称"
		}, {
            field : "custerCode",
            title : "老铁牛客户号"
        }, {
            field : "merchType",
            title : "角色"
        }, {
			field : "enable",
			title : "状态",
			templet : function(data){return data.enable?"启用":"禁用"}
		}, {
            field : "isVerify",
            title : "实名认证",
            templet : function(data){return data.isVerify?"完成":"否"}
        }, {
            field : "isSign",
            title : "合同签署",
            templet : function(data){return data.isSign?"完成":"否"}
        }, {
			field : "createTime",
            width : 160,
			title : "创建时间"
		}, {
			title : "操作",
			width : 150,
			align : "center",
			fixed : "right",
			toolbar : "#table-content-list"
		} ] ],
		page : !0,
		limit : 10,
		limits : [ 10, 15, 20, 25, 30 ],
		text: {none: '暂无相关数据'}
	}), tab.on("tool(LAY-web-list)", function(row) {
		if ("update" === row.event) {
			parent.layer.open({
				type : 2,
				title : "编辑用户",
				content : layui.setter.base + "admin/merch/updatePage?id="
						+ row.data.id,
				maxmin : !0,
				area : [ '600px', '500px' ],
				btn : [ "确定", "取消" ],
				yes : function(index, layero) {
					// 点击确认触发 iframe 内容中的按钮提交
					layero.find('iframe').contents().find(
							"#layuiadmin-app-form-edit").click();
				}
			});
			return;
		}

		if("view" == row.event){
			parent.layer.open({
                type : 2,
                title : "用户详情",
                content : layui.setter.base + "admin/merch/view?id="
                    + row.data.id,
                maxmin : !0,
                area : [ '600px', '500px' ],
                btn : [ "确定", "取消" ],
                yes : function(index, layero) {
                    // 点击确认触发 iframe 内容中的按钮提交
                    layero.find('iframe').contents().find(
                        "#layuiadmin-app-form-edit").click();
                }
            });
            return;
		}

        if("uploadmerch" === row.event){
            console.log(row.data);

            parent.layer.open({
                type: 2
                ,title: '添加'
                ,content: 'admin/merch/uploadmerch?code='+ row.data.code + '&r=' + Math.random()
                ,maxmin: true
                ,area: ['80%', '90%']
                ,btn: ['确定', '取消']
                ,yes: function(index, layero){
                    //点击确认触发 iframe 内容中的按钮提交
                    layero.find('iframe').contents().find("#layuiadmin-app-form-edit").click();
                }
            });
        }

        if("more" === row.event){
            console.log(row.data);

            parent.layer.open({
                type: 2
                ,title: '更多'
                ,content: 'admin/merch/morecz?code='+ row.data.code + '&r=' + Math.random()
                ,maxmin: true
                ,area: ['80%', '90%']
                //,btn: ['', '']
                ,yes: function(index, layero){
                    //点击确认触发 iframe 内容中的按钮提交
                    layero.find('iframe').contents().find("#layuiadmin-app-form-edit").click();
                }
            });
		}

        if ("downmerch" === row.event) {
            console.log(row.data);
            layer.confirm("确定下载吗？", function(e) {
                console.log(row.data);
                window.location.href = layui.setter.base + "admin/merch/downmerch?code="
                    + row.data.code + "&r=" + Math.random();

                layer.close(e);
            });
            return;
        }


		if ("delete" === row.event) {
			layer.confirm("确定删除吗？", function(e) {
				console.log(row.data);
				// 请求删除接口
				layui.admin.req({
					url : layui.setter.base + "admin/merch/delete?id="
							+ row.data.id + "&r=" + Math.random(),
					data : null,
					done : function(res) {
						if (res.code !== 0) {
							layer.msg(res.msg, {
								icon : 2
							});
						} else {
							layer.msg(res.msg, {
								icon : 1
							});
							layui.table.reload('LAY-web-list'); // 重载表格
							layer.close(e); // 再执行关闭
						}
					}
				});
			});
			return;
		}
	}), exports("merch", {})
});
